M=require("ming_node");

const Db= M.getMySql({
  database:"miapi"
})

async function main(){
    let list= M.getObjByFile("tree.json");
    for (let i=0;i<list.length;i++){
        let obj=list[i];
        let sql= M.getInsertObjSql("t_file",obj);
        //console.log("======>",obj)
        let r= await  Db.doSql(sql);
        console.log(i)
        //console.log("==>",sql)
    }

    //更新目录容量
    // Db.doSql(`
    //     UPDATE t_file t1
    //     inner join
    //     (
    //       SELECT sum(s) ds,d from t_file WHERE f=1 GROUP BY d
    //     )t2
    //     on t2.d=t1.p
    //     set t1.s=t2.ds
    //     where t1.f=0
    // `);

   // console.log(list[0]);
}

main()
